package com.softa.common.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.softa.common.dao.SysLogMapper;
import com.softa.common.entity.SysLog;
import com.softa.common.service.LogService;
import com.softa.common.sysconfig.support.DataTableRequest;
import com.softa.common.sysconfig.support.QueryRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author hasee
 */
@Service
public class LogServiceImpl implements LogService {
	
	@Resource
	private SysLogMapper sysLogMapper;
	
	@Override
	public void saveLog(SysLog log) {
		sysLogMapper.insert(log);
	}

	@Override
	public Integer deleteLog(Long id) {
		return sysLogMapper.deleteById(id);
	}

	@Override
	public Page<SysLog> queryLogByparam(DataTableRequest<SysLog> request) {
		Page<SysLog> page = request.startPagePlugin();
		Map<String, Object> params = request.getParams();
		QueryRequest queryRequest = new QueryRequest();
		queryRequest.setParams(params);
		List<SysLog> list = sysLogMapper.selectByCondition(queryRequest);
		page.setRecords(list);
		return page;
	}

}
